package demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2023-09-04
 * Time: 13:17
 */

abstract class Ainmal {
    public String name;
    public int age;

    public Ainmal(String name, int age) {
        this.name = name;
        this.age = age;

    }
    public abstract void eat();
}

interface IFly {
    void fly();
}
interface IRun {
    void run();
}
interface ISwim{
    void swim();
}
class dog extends Ainmal implements IRun {


    public dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void run() {
        System.out.println(this.name +"正在用四条腿奔跑" );
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃狗粮！！！");
    }
}

class forg extends Ainmal implements ISwim,IRun {
    public forg(String name, int age) {
        super(name, age);
    }

    @Override
    public void swim() {
        System.out.println(this.name +"正在用两只脚游" );
    }

    @Override
    public void run() {
        System.out.println(this.name + "正在用两只脚跑");
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃蛙粮！！！");
    }
}

class duck extends Ainmal implements ISwim,IRun,IFly {
    public duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在用两个爪子跑！！");
    }

    @Override
    public void swim() {
        System.out.println(this.name+"正在用两个爪子游！！");
    }

    @Override
    public void fly() {
        System.out.println(this.name+"正在用翅膀飞！！！");
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃鸭粮！！");
    }
}

class roboot implements ISwim,IRun,IFly {

    @Override
    public void fly() {
        System.out.println("用仿生翅膀飞");
    }

    @Override
    public void run() {
        System.out.println("用两条腿跑");
    }

    @Override
    public void swim() {
        System.out.println("用机械臂划着游泳");
    }
}

public class Test {

    public static void func1(Ainmal ainmal) {
        ainmal.eat();
    }

    public static void run(IRun iRun) {
        iRun.run();
    }

    public static void fly(IFly iFly)  {
        iFly.fly();
    }

    public static void swim(ISwim iSwim) {
        iSwim.swim();
    }

    public static void main(String[] args) {

        run(new dog("xiaozi",3));
        run(new duck("sansan",2));
        run(new forg("sana",34));

        run(new roboot());

        System.out.println("=======================");

        fly(new duck("sansan",2));

        System.out.println("=======================");

        swim(new duck("sansan",34));
    }

    public static void main1(String[] args) {
        func1(new dog("xiaozi",3));
        func1(new dog("sansan",2));
        func1(new forg("sana",34));
        System.out.println("=======================");

    }
}
